//
//  MainViewController.m
//  dyseller
//
//  Created by 红喇叭 on 2017/6/1.
//  Copyright © 2017年 红喇叭. All rights reserved.
//

#import "MainViewController.h"
#import "ModuleView.h"
#import "BaiduMapVC.h"
#import "PPHttpRequsetData.h"

@interface MainViewController (){
    UIView *_firstView ;
}

@end

@implementation MainViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:163.0/255.0 green:163.0/255.0 blue:163.0/255.0 alpha:1];
    self.navigationController.navigationBar.translucent = NO;
    [self createModuleView];
    
    UILabel *lav = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 24)];
    lav.textColor = [UIColor redColor];

    lav.text = @"首页";
    lav.textAlignment = NSTextAlignmentCenter;
    self.navigationItem.titleView = lav;
    
    
    __weak typeof(self) weakself = self;
    UIButton *opsuo = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 40, 24)];
    [opsuo setTitle:@"地图" forState:UIControlStateNormal];
    [opsuo setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [opsuo handleControlEvent:UIControlEventTouchUpInside withBlock:^(id sender) {
        BaiduMapVC *vc = [[BaiduMapVC alloc] init];
        [weakself.navigationController pushViewController:vc animated:YES];
    }];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:opsuo];
    
    /*[[PPHttpRequsetData shareInstance] requestStyle:Request_POST URL:@"http://t.6mo.cc/appApi/News/newsChannel" parameter:@{@"session_id":@"6smrchn7fq038d9uot346mc54qbjj6lq"} successBlock:^(NSDictionary *infoMsg) {
        
    } failBlock:^(NSString *errMsg) {
        
    }];*/
    
}


- (void)createModuleView{
    NSArray *imageAr = @[@"icon_spgl",@"icon_ddgl",@"icon_dpgl",@"icon_zbzx",@"icon_srtj",@"icon_fhjf"];
    NSArray *title = @[@"商品管理",@"订单管理",@"店铺管理",@"直播中心",@"收入统计",@"返回积分"];
    for (int i = 0; i < 6; i++) {
        ModuleView *view = [[ModuleView alloc] initWithModeleView:CGRectMake(2+self.view.width/2*(i%2), 5+(self.view.width/2+5)*(i/2), self.view.width/2-4, self.view.width/2-5) title:title[i] imagename:imageAr[i]];
        view.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:view];
    }
}

@end
